home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 80 / CD Actual 80 Julio-Agosto 2003.iso / Linux / LinuxGazette / lg / issue62 / misc / steffler / MakingSmalltalk-Article4.st < prev    next >
Encoding:
Text File  |  2002-08-14  |  9.1 KB  |  272 lines

  1. Browser subclass: #ScopedBrowser
  2.     instanceVariableNames: 'includedCategories excludedClasses includedClasses '
  3.     classVariableNames: ''
  4.     poolDictionaries: ''
  5.     category: 'MakingSmalltalk-Article4'!
  6.  
  7. !ScopedBrowser methodsFor: 'class list' stamp: 'JRS 12/12/2000 09:37'!
  8. classList
  9.     "Override this method to:
  10.         * look up the category index from the system category list, as the browser category index is expected to be different than the system category lists index.
  11.         * reject/include any excluded/included classes
  12.     Answer an array of the class names of the selected category. Answer an empty array if no selection exists."
  13.     | categoryClasses |
  14.     "Use temporary variable here, instead of block variable as I've heard Squeak has/had trouble with block variables."
  15.  
  16.     systemCategoryListIndex = 0
  17.         ifTrue: [^Array new]
  18.         ifFalse: [categoryClasses := (systemOrganizer listAtCategoryNumber: (systemOrganizer categories 
  19.                     indexOf: self selectedSystemCategoryName asSymbol)). 
  20.                 "The implicit logic here, is that if there are both no included and no excluded classes - 
  21.                 no class scope was specified - don't reject any classes."
  22.                 self includedClasses isNil
  23.                     ifTrue: [^categoryClasses reject: [:e | self excludedClasses includes: e name]]
  24.                     ifFalse: [^categoryClasses select: [:e | self includedClasses includes: e name]]].! !
  25.  
  26.  
  27. !ScopedBrowser methodsFor: 'system category list' stamp: 'JRS 11/19/2000 09:16'!
  28. systemCategoryList
  29.     "Override this method to answer the scoped class categories modeled by the receiver."
  30.  
  31.     ^self includedCategories select: [:e | systemOrganizer categories includes: e]! !
  32.  
  33.  
  34. !ScopedBrowser methodsFor: 'accessing' stamp: 'JRS 11/14/2000 09:05'!
  35. excludedClasses 
  36.  
  37.     ^excludedClasses ! !
  38.  
  39. !ScopedBrowser methodsFor: 'accessing' stamp: 'JRS 11/14/2000 09:06'!
  40. excludedClasses: aCollectionOfClasses 
  41.  
  42.     ^excludedClasses := aCollectionOfClasses.! !
  43.  
  44. !ScopedBrowser methodsFor: 'accessing' stamp: 'JRS 11/14/2000 09:05'!
  45. includedCategories
  46.  
  47.     ^includedCategories! !
  48.  
  49. !ScopedBrowser methodsFor: 'accessing' stamp: 'JRS 11/14/2000 09:06'!
  50. includedCategories: aCollectionOfCategories
  51.  
  52.     ^includedCategories := aCollectionOfCategories! !
  53.  
  54. !ScopedBrowser methodsFor: 'accessing' stamp: 'JRS 12/12/2000 09:26'!
  55. includedClasses 
  56.  
  57.     ^includedClasses ! !
  58.  
  59. !ScopedBrowser methodsFor: 'accessing' stamp: 'JRS 12/12/2000 09:26'!
  60. includedClasses: aCollectionOfClasses 
  61.  
  62.     ^includedClasses := aCollectionOfClasses.! !
  63.  
  64. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  65.  
  66. ScopedBrowser class
  67.     instanceVariableNames: ''!
  68.  
  69. !ScopedBrowser class methodsFor: 'instance creation' stamp: 'JRS 11/19/2000 09:09'!
  70. openBrowserWithCategories: aCollectionOfCategorySymbols 
  71.  
  72.     self openBrowserWithCategories: aCollectionOfCategorySymbols 
  73.         withoutClasses: OrderedCollection new
  74.         withLabelSuffix: 'Unknown scope'! !
  75.  
  76. !ScopedBrowser class methodsFor: 'instance creation' stamp: 'JRS 12/12/2000 09:19'!
  77. openBrowserWithCategories: aCollectionOfCategorySymbols withClasses: aCollectionOfClassSymbols
  78.  
  79.     self openBrowserWithCategories: aCollectionOfCategorySymbols 
  80.         withClasses: aCollectionOfClassSymbols
  81.         withLabelSuffix: 'Unknown scope'! !
  82.  
  83. !ScopedBrowser class methodsFor: 'instance creation' stamp: 'JRS 12/12/2000 09:20'!
  84. openBrowserWithCategories: aCollectionOfCategorySymbols withClasses: aCollectionOfClassSymbols withLabelSuffix: aLabelSuffix
  85.  
  86.     | aScopedBrowser |
  87.  
  88.     aScopedBrowser := self new.
  89.     aScopedBrowser includedCategories: aCollectionOfCategorySymbols.
  90.     aScopedBrowser includedClasses: aCollectionOfClassSymbols.
  91.     self openBrowserView: (aScopedBrowser openEditString: nil)
  92.             label: 'Scoped Browser: ', aLabelSuffix        ! !
  93.  
  94. !ScopedBrowser class methodsFor: 'instance creation' stamp: 'JRS 11/19/2000 09:10'!
  95. openBrowserWithCategories: aCollectionOfCategorySymbols withoutClasses: aCollectionOfClassSymbols
  96.  
  97.     self openBrowserWithCategories: aCollectionOfCategorySymbols 
  98.         withoutClasses: aCollectionOfClassSymbols
  99.         withLabelSuffix: 'Unknown scope'! !
  100.  
  101. !ScopedBrowser class methodsFor: 'instance creation' stamp: 'JRS 11/19/2000 09:10'!
  102. openBrowserWithCategories: aCollectionOfCategorySymbols withoutClasses: aCollectionOfClassSymbols withLabelSuffix: aLabelSuffix
  103.  
  104.     | aScopedBrowser |
  105.  
  106.     aScopedBrowser := self new.
  107.     aScopedBrowser includedCategories: aCollectionOfCategorySymbols.
  108.     aScopedBrowser excludedClasses: aCollectionOfClassSymbols.
  109.     self openBrowserView: (aScopedBrowser openEditString: nil)
  110.             label: 'Scoped Browser: ', aLabelSuffix        ! !
  111.  
  112.  
  113. !ScopedBrowser class methodsFor: 'instance creation - Making Smalltalk' stamp: 'JRS 12/17/2000 09:43'!
  114. openBrowserForArticle3
  115.     "Scopes the browser for Making Smalltalk 
  116.     (www.magma.ca/~jagwar/makingSmalltalkForwardingPage.html, article 3"
  117.  
  118.     self openBrowserWithCategories: (OrderedCollection new 
  119.             add: 'Collections-Abstract' asSymbol; 
  120.             add: 'Collections-Sequenceable' asSymbol;
  121.             add: 'Collections-Unordered' asSymbol;
  122.             yourself)
  123.         withoutClasses: (OrderedCollection new
  124.             add: #ArrayedCollection;
  125.             add: #SharedQueue;
  126.             add: #MappedCollection;
  127.             add: #Interval;
  128.             add: #IdentityDictionary;
  129.             add: #IdentitySet;
  130.             add: #PluggableDictionary;
  131.             add: #PluggableSet;
  132.             yourself)
  133.         withLabelSuffix: 'Making Smalltalk - Article 3 scope'! !
  134.  
  135. !ScopedBrowser class methodsFor: 'instance creation - Making Smalltalk' stamp: 'JRS 12/17/2000 09:43'!
  136. openBrowserForArticle4
  137.     "Scopes the browser for Making Smalltalk 
  138.     (www.magma.ca/~jagwar/makingSmalltalkForwardingPage.html, article 4"
  139.  
  140.     self openBrowserWithCategories: (OrderedCollection new 
  141.             add: 'Collections-Abstract' asSymbol; 
  142.             add: 'Collections-Sequenceable' asSymbol;
  143.             add: 'Collections-Unordered' asSymbol;
  144.             add: 'Kernel-Objects' asSymbol;
  145.             add: 'Kernel-ST80 Remnants';
  146.             add: 'MakingSmalltalk-Article2' asSymbol;
  147.             add: 'MakingSmalltalk-Article4' asSymbol;
  148.             yourself)
  149.         withClasses: (OrderedCollection new
  150.             add: #Collection;
  151.             add: #SequenceableCollection;
  152.  
  153.             add: #Heap;
  154.             add: #LinkedList;
  155.             add: #OrderedCollection;
  156.             add: #SortedCollection;
  157.  
  158.             add: #Bag;
  159.             add: #Dictionary;
  160.             add: #Set;
  161.  
  162.             add: #Boolean;
  163.             add: #False;
  164.             add: #Object;
  165.             add: #True;
  166.  
  167.             add: #Workspace;
  168.  
  169.             add: #Person;
  170.             add: #ScopedBrowser;
  171.             yourself)
  172.         withLabelSuffix: 'Making Smalltalk - Article 4 scope'! !
  173.  
  174.  
  175. !ScopedBrowser class methodsFor: 'unit testing' stamp: 'JRS 12/12/2000 09:35'!
  176. openBrowserTest
  177.     "Test category scope creation method"
  178.  
  179.     self openBrowserWithCategories: (OrderedCollection new 
  180.             add: 'Collections-Abstract' asSymbol;
  181.             yourself)! !
  182.  
  183. !ScopedBrowser class methodsFor: 'unit testing' stamp: 'JRS 12/12/2000 09:35'!
  184. openBrowserTest2
  185.     "Test exclude classes creation method"
  186.  
  187.     self openBrowserWithCategories: (OrderedCollection new 
  188.             add: 'Collections-Abstract' asSymbol;
  189.             yourself)
  190.         withoutClasses: (OrderedCollection new
  191.             add: #Collection;
  192.             yourself)! !
  193.  
  194. !ScopedBrowser class methodsFor: 'unit testing' stamp: 'JRS 12/12/2000 09:36'!
  195. openBrowserTest3
  196.     "Test exclude classes creation method"
  197.  
  198.     self openBrowserWithCategories: (OrderedCollection new 
  199.             add: 'Collections-Abstract' asSymbol;
  200.             yourself)
  201.         withoutClasses: (OrderedCollection new
  202.             add: #Collection;
  203.             yourself)
  204.         withLabelSuffix: 'Testing Scope'! !
  205.  
  206. !ScopedBrowser class methodsFor: 'unit testing' stamp: 'JRS 11/19/2000 09:21'!
  207. openBrowserTest4
  208.     "Test instantiating with a non-existant category"
  209.  
  210.     self openBrowserWithCategories: (OrderedCollection new 
  211.             add: 'asdfasdfd-ereeff' asSymbol; 
  212.             add: 'Collections-Abstract' asSymbol;
  213.             yourself)
  214.         withoutClasses: (OrderedCollection new
  215.             add: #Collection;
  216.             yourself)
  217.         withLabelSuffix: 'Testing nonexistant category'! !
  218.  
  219. !ScopedBrowser class methodsFor: 'unit testing' stamp: 'JRS 12/12/2000 09:41'!
  220. openBrowserTest5
  221.     "Test instantiating with a non-existant class to exclude"
  222.  
  223.     self openBrowserWithCategories: (OrderedCollection new 
  224.             add: 'asdfasdfd-ereeff' asSymbol; 
  225.             add: 'Collections-Abstract' asSymbol;
  226.             yourself)
  227.         withoutClasses: (OrderedCollection new
  228.             add: #Aadfdfefff;
  229.             yourself)
  230.         withLabelSuffix: 'Testing nonexistant class to exclude'! !
  231.  
  232. !ScopedBrowser class methodsFor: 'unit testing' stamp: 'JRS 12/12/2000 09:35'!
  233. openBrowserTest6
  234.     "Test include classes creation method"
  235.  
  236.     self openBrowserWithCategories: (OrderedCollection new 
  237.             add: 'Collections-Abstract' asSymbol;
  238.             yourself)
  239.         withClasses: (OrderedCollection new
  240.             add: #Collection;
  241.             yourself)! !
  242.  
  243. !ScopedBrowser class methodsFor: 'unit testing' stamp: 'JRS 12/12/2000 09:39'!
  244. openBrowserTest7
  245.     "Test include classes creation method"
  246.  
  247.     self openBrowserWithCategories: (OrderedCollection new 
  248.             add: 'Collections-Abstract' asSymbol;
  249.             yourself)
  250.         withClasses: (OrderedCollection new
  251.             add: #Collection;
  252.             yourself)
  253.         withLabelSuffix: 'Testing Scope'! !
  254.  
  255. !ScopedBrowser class methodsFor: 'unit testing' stamp: 'JRS 12/12/2000 09:41'!
  256. openBrowserTest8
  257.     "Test instantiating with a non-existant class to include"
  258.  
  259.     self openBrowserWithCategories: (OrderedCollection new 
  260.             add: 'asdfasdfd-ereeff' asSymbol; 
  261.             add: 'Collections-Abstract' asSymbol;
  262.             yourself)
  263.         withClasses: (OrderedCollection new
  264.             add: #Aadfdfefff;
  265.             yourself)
  266.         withLabelSuffix: 'Testing nonexistant class to include'! !
  267.  
  268.  
  269. !ScopedBrowser class methodsFor: 'testing' stamp: 'JRS 12/13/2000 10:34'!
  270. version
  271.  
  272.     ^1.1! !